package ru.home.documentmanager.dao.impl;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import ru.home.documentmanager.dao.FileDocDAO;
import ru.home.documentmanager.model.FileDoc;
import ru.home.documentmanager.model.User;

@Repository("fileDocDAO")
public class FileDocDAOImpl extends AbstractDAO<FileDoc> implements FileDocDAO {

    public FileDocDAOImpl() {
        super(FileDoc.class);
    }

    @Override
    public FileDoc find(String name, User user) {
        return (FileDoc) getSession()
                .createCriteria(FileDoc.class)
                .add(Restrictions.and(Restrictions.eq("name", name),
                        Restrictions.eq("user", user))).uniqueResult();
    }

}
